#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>

int main(int argc, char const *argv[])
{
    int a = 100;
    pid_t pid = fork();

    if( pid > 0 )
    {
        a++;
        printf("父进程id:%d ,a=%d , 子进程id:%d ,地址:%p\r\n",getpid() ,a , pid  ,&a);
    }else if( pid == 0 )
    {
        a--;
        printf("子进程id:%d ,a=%d , 父进程id:%d ,地址:%p\n",getpid()  ,a ,getppid() ,&a);
    }

    printf("进程:%d执行结束\n",getpid());
    return 0;
}
